package br.mg.bhe.ftpobre.fs.compare;

import java.util.Comparator;

import org.apache.commons.net.ftp.FTPFile;

import br.mg.bhe.ftpobre.fs.RemoteFile;

/**
 * Files and Folders.
 * 
 * @author Aureliano
 */
public class CompareRemoteFilesByLogicalType implements Comparator<RemoteFile> {

	@Override
	public int compare(RemoteFile file1, RemoteFile file2) {
		if (file1.getFile().getType() == file2.getFile().getType()) {
			return file1.getFile().getName().compareTo(file2.getFile().getName());
		}
		
		if (file1.getFile().getType() == FTPFile.DIRECTORY_TYPE) {
			return -1;
		} else {
			return 1;
		}
	}
}